<?php
/* ******************************************************** */
/* Arcans Project (2010)                                    */
/* Jeu 3D en temps réel par navigateur, conception et       */
/* Développement dans la notice                             */
/* Jeu sous licence GNU GPL v3 (voir NOTICE et COPYING)     */
/* ******************************************************** */

//*********************************
//classe de création du header html
//*********************************
class HeaderClass {
	//propriétés :
	private $title;
	private $charset;
	private $style;
	//méthodes :
	function __construct($type, $obj_xml, $title, $infos) {
		$this->title = $infos["title"]." - ".$title;
		$this->charset = $infos["charset"];
		$this->style = $infos["style"];
		if ($type == "classic") $this->infos = $obj_xml;
		elseif ($type == "panel") $this->infos = "panel";
	}
	public function affichage() {
		echo '<title>'.$this->title.'</title>';
		echo '<meta http-equiv="Content-Type" content="text/html; charset='.$this->charset.'" />';
		echo '<meta http-equiv="pragma" content="no-cache">';
		echo '<link type="text/css" rel="stylesheet" href="'.$this->style.'" />';

		if ($this->infos == "panel") {
			echo '<script type="text/javascript" src="javascript/panel.js"></script>';
			echo '<script type="text/javascript" src="javascript/chat.js"></script>';
			echo '<script type="text/javascript" src="javascript/imail.js"></script>';
		}
		else {
			echo '<meta http-equiv="refresh" content="2000;url=?p=i" />';
			echo '<script type="text/javascript" src="javascript/onload.js"></script>';
			echo '<script type="text/javascript" src="javascript/bao.js"></script>';
			if ($this->infos[0]["type"] != "noinfos") $this->infosAff();
			if (isset($_SESSION["pseudo"])) {
				echo '<script type="text/javascript" src="javascript/decon.js"></script>';
				echo '<script type="text/javascript" src="javascript/messages.js"></script>';
				echo '<script type="text/javascript" src="javascript/chat.js"></script>';
				echo '<script type="text/javascript" src="javascript/imail.js"></script>';
			}
			else {
				echo '<script type="text/javascript" src="javascript/login.js"></script>';
			}
		}
	}
	public function affichageXML($doc, $html) {
		header("Content-Type: text/plain");//####################################### pour les tests
		$head = $doc->createElement('head');
		//$html->appendChild($head);

		// TITRE
		$titre = $doc->createElement('title', $this->title);
		$head->appendChild($titre);
		$html->appendChild($head);

		// CSS
		$style = $doc->createElement("link");
		$style->setAttribute("type","text/css");
		$style->setAttribute("rel","stylesheet");
		$style->setAttribute("href",$this->style);
		$head->appendChild($style);

		// META
		$meta = $doc->createElement("meta");
		$meta->setAttribute('http-equiv','Content-Type');
		$meta->setAttribute('content','text/html');
		$meta->setAttribute('charset',$this->charset);
		$head->appendChild($meta);

		$meta = $doc->createElement("meta");
		$meta->setAttribute('http-equiv','pragma');
		$meta->setAttribute('content','no-cache');
		$head->appendChild($meta);

		//$this->infos = "panel";
		if ($this->infos == "panel") {
			$script = $doc->createElement("script");
			$script->setAttribute('type','text/javascript');
			$script->setAttribute('src','javascript/panel.js');
			$head->appendChild($script);

			$script = $doc->createElement("script");
			$script->setAttribute('type','text/javascript');
			$script->setAttribute('src','javascript/chat.js');
			$head->appendChild($script);

			$script = $doc->createElement("script");
			$script->setAttribute('type','text/javascript');
			$script->setAttribute('src','javascript/imail.js');
			$head->appendChild($script);

			//echo '<script type="text/javascript" src="javascript/panel.js"></script>';
			//echo '<script type="text/javascript" src="javascript/chat.js"></script>';
			//echo '<script type="text/javascript" src="javascript/imail.js"></script>';
		}
		else {
			$meta = $doc->createElement("meta");
			$meta->setAttribute('http-equiv','refresh');
			$meta->setAttribute('content','2000;url=?p=i');
			$head->appendChild($meta);

			//echo '<meta http-equiv="refresh" content="2000;url=?p=i" />';

			$script = $doc->createElement("script");
			$script->setAttribute('type','text/javascript');
			$script->setAttribute('src','javascript/onload.js');
			$head->appendChild($script);

			$script = $doc->createElement("script");
			$script->setAttribute('type','text/javascript');
			$script->setAttribute('src','javascript/bao.js');
			$head->appendChild($script);

			$script = $doc->createElement("script");
			$script->setAttribute('type','text/javascript');
			$script->setAttribute('src','javascript/messages.js');
			$head->appendChild($script);

			//echo '<script type="text/javascript" src="javascript/onload.js"></script>';
			//echo '<script type="text/javascript" src="javascript/bao.js"></script>';

			//$this->infos[0]["type"] = "javascript";
			if ($this->infos[0]["type"] != "noinfos") {
				$this->infosAff($doc, $head);
			}

			if (isset($_SESSION["pseudo"])) {
				$script = $doc->createElement("script");
				$script->setAttribute('type','text/javascript');
				$script->setAttribute('src','javascript/decon.js');
				$head->appendChild($script);

				$script = $doc->createElement("script");
				$script->setAttribute('type','text/javascript');
				$script->setAttribute('src','javascript/messages.js');
				$head->appendChild($script);

				$script = $doc->createElement("script");
				$script->setAttribute('type','text/javascript');
				$script->setAttribute('src','javascript/chat.js');
				$head->appendChild($script);

				$script = $doc->createElement("script");
				$script->setAttribute('type','text/javascript');
				$script->setAttribute('src','javascript/imail.js');
				$head->appendChild($script);

				//echo '<script type="text/javascript" src="javascript/decon.js"></script>';
				//echo '<script type="text/javascript" src="javascript/messages.js"></script>';
				//echo '<script type="text/javascript" src="javascript/chat.js"></script>';
				//echo '<script type="text/javascript" src="javascript/imail.js"></script>';
			}
			else {
				$script = $doc->createElement("script");
				$script->setAttribute('type','text/javascript');
				$script->setAttribute('src','javascript/login.js');
				$head->appendChild($script);

				//echo '<script type="text/javascript" src="javascript/login.js"></script>';
			}
		}
	}
	private function infosAff($doc, $head) {
		foreach ($this->infos as $elt) {
			switch ($elt["type"]) {
				case "javascript" :
					/*$script = $doc->createElement("script");
					 $script->setAttribute('src','javascript/'.$elt["path"]);
					 $head->appendChild($script);*/
					//echo '<script type="text/javascript" src="javascript/'.$elt["path"].'"></script>';
					break;
			}
		}
	}
}
//******************************
//classe de création de l'entete
//******************************
class EnteteClass {
	//propriétés :
	private $E_title;
	private $E_subtitle;
	//méthodes :
	function __construct() {
		$this->E_title = "Arcans Project";
		$this->E_subtitle = "Tactical RPG par navigateur";
	}
	public function affichage() {
		echo '<td id="logo1">&nbsp;</td><td id="titletd"><a href="?p=i">'.$this->E_title.'</a><br />';
		echo $this->E_subtitle.'</td>';
	}
	public function affichageXML($doc, $table_entete) {
		$td_logo1 = $doc->createElement("td");
		$td_logo1->setAttribute('id','logo1');
		$td_logo1->appendChild($doc->createTextNode(' '));
		$table_entete->appendChild($td_logo1);

		$td_titletd = $doc->createElement("td");
		$td_titletd->setAttribute('id','titletd');
		$table_entete->appendChild($td_titletd);

		$lien = $doc->createElement("a");
		$lien->setAttribute('href','?p=i');
		$lien->appendChild($doc->createTextNode($this->E_title));
		$td_titletd->appendChild($lien);


		$retour_ligne = $doc->createElement("br");
		$td_titletd->appendChild($retour_ligne);

		$td_titletd->appendChild($doc->createTextNode($this->E_subtitle));

		//echo '<td id="logo1">&nbsp;</td><td id="titletd"><a href="?p=i">'.$this->E_title.'</a><br />';
		//echo $this->E_subtitle.'</td>';
	}
}
?>